<root xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="rds.html" />

<report>

    <?python
        from mnemoply.utils import format_date

        register = model.DailyPaymentRegister.get(ids[0])
        date = register.creation_date
        cash_register = register.cashRegister
        organization = register.organization
        pay_records = []
        for pr in model.PaymentRecord.selectBy(date=date, register=cash_register):
            if pr.studentAgreement.organization == organization:
                pay_records.append(pr)
    ?>

    <registertitle py:content="register.title" />
    <id py:content="register.id" />
    <cash_register py:content="cash_register.name" /> <!--TODO: fix field in template-->
    <date py:content="format_date(register.creation_date)" />
    <registeramount py:content="register.amount" />

    <payment_record py:for="num, pr in enumerate(pay_records)">
        <enum py:content="num + 1" />
        <customer>${pr.studentAgreement.customer.surname} ${pr.studentAgreement.customer.forename} ${pr.studentAgreement.customer.patronymic}</customer>
        <student>${pr.student.surname} ${pr.student.forename} ${pr.student.patronymic}</student>
        <group>${pr.getGroupTitle()}</group>
        <amount>${pr.amount}</amount>
    </payment_record>

</report>

</root>
